﻿Public Class UC_QuanLyKhachHang

    Private Sub PanelControl2_Paint(sender As Object, e As PaintEventArgs) Handles PanelControl2.Paint

    End Sub

    Private Sub SimpleButton2_Click(sender As Object, e As EventArgs) Handles SimpleButton2.Click
        Dim f As New F_KhachHang
        f.ShowDialog()
        loadgv
    End Sub

    Private Sub btnEdit_Click(sender As Object, e As EventArgs) Handles btnEdit.Click
        sendDataToFormKhachHang()
        loadgv
    End Sub
    Sub sendDataToFormKhachHang()
        Dim kh As New DTOKhachHang
        kh.MaKH = Convert.ToInt16(gvKhachHang.CurrentRow.Cells("makh").Value)
        kh.TenKH = gvKhachHang.CurrentRow.Cells("tenkh").Value
        kh.NgaySinh = gvKhachHang.CurrentRow.Cells("ngaysinh").Value
        kh.DiaChi = gvKhachHang.CurrentRow.Cells("diachi").Value
        kh.DienThoai = gvKhachHang.CurrentRow.Cells("dienthoai").Value
        Dim f As New F_KhachHang
        Dim action As Integer = 0 'Hanh dong update
        f.receiveData(kh,action)
        f.ShowDialog()
    End Sub
    Private Sub UC_QuanLyKhachHang_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        loadgv
    End Sub

    Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
       loadgv
    End Sub
    Public Sub loadgv()
        gvKhachHang.DataSource = BUSKhachHang.KhachHang_Load
    End Sub

    Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
        If AgreeForm.deleteCaution = False Then
            Return
        End If
        Dim kh As New DTOKhachHang
        kh.MaKH = Convert.ToInt16(gvKhachHang.CurrentRow.Cells("makh").Value)
        BUSKhachHang.KhachHang_Delete(kh)
        loadgv
    End Sub
End Class
